var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
    })(t, e);
}, function(t, e) {
    function i() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, 
    new i());
}), a = this && this.__decorate || function(t, e, o, i) {
    var c, n = arguments.length, r = n < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i); else for (var s = t.length - 1; 0 <= s; s--) (c = t[s]) && (r = (n < 3 ? c(r) : 3 < n ? c(e, o, r) : c(e, o)) || r);
    return 3 < n && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("ScrollGameItem"), s = e("Global"), c = e("GameConfig"), l = e("WebManager"), d = cc._decorator, u = d.ccclass, p = d.property, h = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.scrollview = null, t.itemtemp = null, t.type = 261, t.autoscrolltime = 2, 
        t.scrolltime = 0, t.direction = 1, t.isStretch = !1, t;
    }
    return i(t, e), t.prototype.onLoad = function() {
        c.GC.isScrollGames ? (this.isStretch && (this.node.width = cc.winSize.width), this.itemtemp.active = !1, 
        this.setType(this.type)) : this.node.destroy();
    }, t.prototype.finish = function() {
        this.scrollview.content.children.forEach(function(t, e) {
            (0 < e ? cc.tween(t).delay(.1 * e) : cc.tween(t)).to(.5, {
                scale: 1
            }).start();
        });
    }, t.prototype.start = function() {}, t.prototype.setType = function(t) {
        var e = this;
        s.G.isMpCheckChannel || l.default.getInstance().redirectPoll({
            Appid: GA.Info.appId,
            Type: t,
            IsIOS: s.G.isIOS,
            success: function(t) {
                0 == t.data.code && e.updateWithData(t.data.data);
            }
        });
    }, t.prototype.update = function(t) {
        !s.G.isMpCheckChannel && (this.scrolltime += t, this.scrolltime >= this.autoscrolltime) && (this.scrolltime = 0, 
        t = this.scrollview.getScrollOffset().x, Math.abs(+t) < 1 ? this.direction = 1 : Math.abs(t + this.scrollview.getMaxScrollOffset().x) < 1 && (this.direction = -1), 
        t = this.direction * this.itemtemp.width + -1 * this.scrollview.getScrollOffset().x, 
        t = Math.round(t / this.itemtemp.width) * this.itemtemp.width, this.scrollview.scrollToOffset(cc.v2(t, 0), 1));
    }, t.prototype.updateWithData = function(t) {
        var i = this;
        this.scrollview && (this.scrollview.content.width = t.length * this.itemtemp.width, 
        t.forEach(function(t, e) {
            var o = cc.instantiate(i.itemtemp);
            o.parent = i.scrollview.content, o.setPosition(cc.v2(i.itemtemp.width * e, 0)), 
            o.active = !0, o.getComponent(r.default).setInfo({
                appid: t.appid,
                name: t.name,
                is_open_code: t.is_open_code,
                icon: t.icon,
                path: t.path,
                qr_code: t.qr_code
            }, i.type);
        }), this.finish(t));
    }, t.prototype.onScrollViewEvent = function() {
        this.scrolltime = 0;
    }, a([ p(cc.ScrollView) ], t.prototype, "scrollview", void 0), a([ p(cc.Node) ], t.prototype, "itemtemp", void 0), 
    a([ p ], t.prototype, "isStretch", void 0), a([ u ], t);
}(cc.Component);

n.default = h;